﻿using D.Medicalcare.Domain.Entities;
using D.Medicalcare.ErrorCode;
using D.Medicalcare.Infrastructure.Interfaces;
using D.Medicalcare.Read.API.Application.Command.ReserInstrucCommand;
using MediatR;

namespace D.Medicalcare.Read.API.Application.Handler.ReserInstrucHarder
{
    public class GetReserInstrucHarder : IRequestHandler<GetReserInstrucCommand, APIResult<List<ReserInstruc>>>
    {

        private readonly IBaseRepository<ReserInstruc> repository;

        public GetReserInstrucHarder(IBaseRepository<ReserInstruc> repository)
        {
            this.repository = repository;
        }

        public async Task<APIResult<List<ReserInstruc>>> Handle(GetReserInstrucCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<ReserInstruc>> result = new APIResult<List<ReserInstruc>>();
            var list = repository.GetAll().ToList();
            result.Code = APIEnum.Mvc;
            result.Msg = "查询成功";
            result.Data = list;
            return await Task.FromResult(result);
        }
    }
}
